﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using System.Data;

namespace BaccaratRally.DataKernel.Service
{
    using BaccaratRally.DataKernel.SqlGateway;
    using BaccaratRally.DataKernel.Entity;

    public class SiteService : ServiceBase
    {
        public virtual Site Create(Site newItem)
        {
            return SqlGateway.CreateInstance().Insert<Site>(newItem);
        }

        public virtual Site Update(Site item)
        {
            return SqlGateway.CreateInstance().Update<Site>(item);
        }

        public virtual List<Site> GetSiteList()
        {
            StringBuilder sqlstring = new StringBuilder();
            sqlstring.Append("SELECT * FROM Site");

            return SqlGateway.CreateInstance().Select<Site>(sqlstring.ToString(), CommandType.Text).ToList();
        }

        public virtual Site GetSite()
        {
            StringBuilder sqlstring = new StringBuilder();
            sqlstring.Append("SELECT * FROM dbo.[Site]");

            return SqlGateway.CreateInstance().SelectSingle<Site>(sqlstring.ToString(), CommandType.Text);
        }
    }
}
